package com.hnucm.cooklife.custom;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SearchView;

import com.hnucm.cooklife.R;

public class SearchLayout extends SearchView {

    private int l,r,t,b;
    private Paint mPaint;

    public SearchLayout(@NonNull Context context) {
        super(context,null,0);
    }

    public SearchLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs,0);
    }

    public SearchLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
//        super.onLayout(changed, left, top, right, bottom);
        l = left;
        r = right;
        t = top;
        b = bottom;
        super.onLayout(changed,left,top,right,bottom);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        initPaint();
        @SuppressLint("DrawAllocation") RectF rect = new RectF(50, 10, 200, 120);
        canvas.drawRoundRect(rect, 20, 10, mPaint);
    }

    @SuppressLint("ResourceAsColor")
    private void initPaint() {
        mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setColor(R.color.blue);
        mPaint.setStyle(Paint.Style.FILL);
    }
}
